<div id="header">
	<div id="logo">
		<div id="logo-left"></div>
		<div id="logo-right">Xin chào, <span class="black"><?php echo $_SESSION['username']." ";?></span> 
			<a href="#" class="img-admin">&nbsp;</a>
			<ul>
				<li><a href="<?php echo base_url()?>back_end/admin_ahashop/infomation">- Information</a></li>
				<li><a href="<?php echo base_url()?>" target="_blank">- Homepage</a></li>
				<li><a href="<?php echo base_url()?>back_end/admin/logout">- Logout</a></li>                      
			</ul>
		</div>
		<div class="clear"></div>
	</div>
<?php
	if ($_SESSION['admin_id'] == 1){
		$menu_1		   = $this->db->get_where('admin_menu', array('status'=>1, 'cat_id'=>0))->result_array();
		
		$url_segment = $this->uri->segment(2);
		switch ($url_segment)
		{
			case "admin_admin":
			case "admin_group":
				$active = 0;
				break;
			case "admin_menu":
			case "admin_system":
			case "admin_log":
				$active = 1;
				break;
			case "admin_country":
			case "admin_province":
			case "admin_district":
			case "admin_ward":
			case "admin_unit":
			case "admin_currency":
			case "admin_video":
			case "admin_support_online":
			case "admin_story":
			case "admin_partner":
			case "admin_document":
				$active = 2;
				break;
			case "admin_introduct":
			case "admin_job":
			case "admin_menu_link":
			case "admin_website_system":
				$active = 3;
				break;
			case "admin_category":
			case "admin_category_2":
			case "admin_category_3":
			case "admin_category_4":
				$active = 4;
				break;
			case "admin_news":
			case "admin_news_category":
			case "admin_news_category_2":
			case "admin_news_category_3":
			case "admin_news_position":
				$active = 5;
				break;
			case "admin_product":
			case "admin_supplier":
				$active = 6;
				break;
			case "admin_ads":
			case "admin_ads_page":
			case "admin_ads_position":
			case "admin_ads_size":
				$active = 7;
				break;
			case "admin_contact":
				$active = 8;
				break;
			case "admin_services_menu":
			case "admin_services":
				$active = 9;
				break;
			default:
				$active = 0;
				break;
		}
?>
    <div id="wrapper">
        <ul id="topnav">
        <?php
        	$i = 0; 
        	foreach ($menu_1 as $m1){?>
           		<li <?php if ($i == $active){?> class="active" <?php }?>>
           			<a href="<?php echo $m1['link']?>"><?php echo $m1['name']?></a>
					<?php 
						$menu_2		   = $this->db->get_where('admin_menu', array('status'=>1, 'cat_id !='=>0, 'cat_id'=>$m1['id']))->result_array();
						if (!empty($menu_2)){
					?>
                	<ul class="children">
                		<?php foreach ($menu_2 as $m2){
                			if ($m1['id'] == $m2['cat_id']){?>
                   				<li><a href="<?php echo base_url()."back_end/".$m2 ['link']?>" <?php if ($m2['controller']==$url_segment){ echo 'style="color: #FFFFFF; font-weight: bold; text-decoration:underline;"'; }?> ><?php echo $m2 ['name'];?></a></li>
                   			<?php }}?>                   
                	</ul>
					<?php }?>
           		</li>
           	<?php $i++;}?>           
        </ul>        
    </div><!--end #wrapper-->
</div>
<?php }else{
	$admin_id      = $_SESSION['admin_id'];
	$table_admin   = $this->db->get_where('admins', array('id' => $admin_id));
	$admin         = $table_admin->row_array();
	$admin_permiss = $this->db->get_where('admin_permiss', array('group_admin_id' => $admin['admin_group_id'], 'access' => '1'));
?>
	<div id="wrapper">
        <ul id="topnav">
       		<?php
       			if($admin_permiss->num_rows() >0)
       			{
       				foreach($admin_permiss->result_array() as $permiss)
       				{
						$menu_1		 = $this->db->get_where('admin_menu', array('cat_id'=>0, 'id'=>$permiss['menu_admin_id']))->result_array();
						$menu_2		 = $this->db->get_where('admin_menu', array('cat_id !='=>0))->result_array();						
       					$url_segment = $this->uri->segment(2);
						switch ($url_segment)
						{
							case "admin_admin":
							case "admin_group":
								$active = 0;
								break;
							case "admin_menu":
							case "admin_system":
							case "admin_log":
								$active = 1;
								break;
							case "admin_country":
							case "admin_province":
							case "admin_district":
							case "admin_ward":
							case "admin_unit":
							case "admin_currency":
							case "admin_video":
							case "admin_support_online":
							case "admin_story":
							case "admin_partner":
							case "admin_document":
								$active = 2;
								break;
							case "admin_introduct":
							case "admin_job":
							case "admin_menu_link":
							case "admin_website_system":
								$active = 3;
								break;
							case "admin_category":
							case "admin_category_2":
							case "admin_category_3":
							case "admin_category_4":
								$active = 4;
								break;
							case "admin_news":
							case "admin_news_category":
							case "admin_news_category_2":
							case "admin_news_category_3":
							case "admin_news_position":
								$active = 5;
								break;
							case "admin_product":
							case "admin_supplier":
								$active = 6;
								break;
							case "admin_ads":
							case "admin_ads_page":
							case "admin_ads_position":
							case "admin_ads_size":
								$active = 7;
								break;
							case "admin_contact":
								$active = 8;
								break;
							case "admin_services_menu":
							case "admin_services":
								$active = 9;
								break;
							default:
								$active = 0;
								break;
						}
			?>
			<?php
				$i	= 0;
        		foreach ($menu_1 as $m1){?>
           			<li <?php if ($i == $active){?> class="active" <?php }?>>
           				<a href="<?php echo $m1['link']?>"><?php echo $m1['name']?></a>
                		<ul class="children">
                			<?php foreach ($menu_2 as $m2){
                				if ($m1['id'] == $m2['cat_id']){?>
                   					<li><a href="<?php echo base_url()."back_end/".$m2 ['link']?>" <?php if ($m2['controller']==$url_segment){ echo 'style="color: #FFFFFF; font-weight: bold; text-decoration:underline;"'; }?> ><?php echo $m2 ['name'];?></a></li>
                   			<?php }}?>                   
                		</ul>
           			</li>
           	<?php $i++;}}}?>           
        </ul>        
    </div><!--end #wrapper-->
<?php }?>